#include "Firewall.h"
#include "CTile.h"
#include "Game Objects/CGrenade.h"
#include "Wrappers/CSGD_Direct3D.h"

CFirewall::CFirewall()
{
	Effect.LoadEffect(".\\Resource\\XML\\walleff.xml");
	isblocking = true;
	SetWidth(64);
	SetHeight(64);
	SetVelX(0);
	SetVelY(0);
	SetType(CBase::OBJ_FIREWALL);
	
}

void CFirewall::Update(float fElapsedTime)
{
	if(isblocking)
	{
		Effect.update(fElapsedTime);
	}
}


void CFirewall::Render(void)
{
	if(isblocking)
	{
		Effect.render();
	}
	
}

bool CFirewall::CheckCollision(IBaseInterface* pBase)
{
	if(pBase->GetType() == OBJ_GRENADE)
	{
		CGrenade* tempg = (CGrenade*)pBase;
		if(tempg->GetGrenadeType() == CGrenade::FW_GRENADE)
		{
			RECT tempr;
			if(tempg->GetExploding())
			{
				if(IntersectRect(&tempr, &this->GetRect(), &tempg->GetExRadius()))
				{
					isblocking = false;
				}	
			}
		}
	}

	return false;
}

CFirewall::~CFirewall(void)
{

}